package 力扣日常刷题.木22一月.第12天0120;

/**
 * @author 帅小伙
 * @date 2022/1/20
 * @description
 */
public class Demo37动态规划中等旋转数字 {


    public int rotatedDigits(int n) {
        int ans = 0;
        for (int i = 1; i <= n ; i++) {
            if(good(i,false)) ans++;
        }
        return ans;
    }

    boolean good(int n,boolean isGood){
        if (n == 0) return isGood;

        int d =  n % 10;
        if(d==3||d==4||d==7)return false;
        if(d==0||d==1||d==8)return good(n/10,isGood);
        return good(n/10,true);
    }

}
